﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using AutoMapper;

namespace MyMvc.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            var UserList = new List<Models.User>();
            UserList.Add(new Models.User { Id = 1, Name = "zhangsan", Age = 18, add_time = DateTime.Now });
            UserList.Add(new Models.User { Id = 2, Name = "lisi", Age = 20, add_time = DateTime.Now.AddDays(1) });
            UserList.Add(new Models.User { Id = 3, Name = "wangwu", Age = 22, add_time = DateTime.Now.AddDays(2) });
            UserList.Add(new Models.User { Id = 4,  Age = 54, Name="mazi", add_time = DateTime.Now.AddDays(2) });
            UserList.Add(new Models.User { Id = 4, Age = 9, add_time = DateTime.Now.AddDays(2) });

            var userview = Mapper.Map<List<Models.User>, List<Models.UserView>>(UserList);
             
            //ViewBag.uv = userview;

            return View(userview);
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }
    }
}